package com.tiantian.quanminxiu.api;

import com.tiantian.quanminxiu.utils.Constants;
import com.tiantian.quanminxiu.utils.JsonConverterFactory;

import org.json.JSONObject;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import retrofit2.http.Part;
import rx.Observable;

public interface AnchorService {

    class Factory {
        public static AnchorService create() {
            Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl(Constants.SERVER_URL+"mobile/")
                    .addConverterFactory(JsonConverterFactory.create())
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();
            return retrofit.create(AnchorService.class);
        }
    }
    //region 开机请求 response
    @FormUrlEncoded
    @POST("response")
    Observable<JSONObject> response(@Field("equ_c")String equ_c, @Field("equ_t")int equ_t,@Field("app_t")int app_t);
    //endregion

    //region 打开请求 open
    @FormUrlEncoded
    @POST("open")
    Observable<JSONObject> open(@Field("mid")int mid, @Field("app_t")int app_t,@Field("sign")String sign
    ,@Field("equ_n")String equ_n, @Field("s_h")int s_h,@Field("s_w")int s_w
    ,@Field("os_v")String os_v, @Field("app_v")String app_v,@Field("app_vc")int app_vc
    ,@Field("lon")double lon, @Field("lat")double lat);
    //endregion

    //region 用户登录 login
    @FormUrlEncoded
    @POST("login")
    Observable<JSONObject> login(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("lname")String lname,@Field("lpw")String lpw);
    //endregion

    //region 获取礼物列表 giftlist
    @FormUrlEncoded
    @POST("giftlist")
    Observable<JSONObject> giftlist(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t);
    //endregion

    //region 更新用户信息 user_userinfo_update
    @FormUrlEncoded
    @POST("user/user-info/update")
    Observable<JSONObject> user_userinfo_update(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t,
                                                @Field("NickName")String NickName,@Field("Signature")String Signature,@Field("Sex")int Sex);
    //endregion

    //region 首页横幅 banner
    @FormUrlEncoded
    @POST("banner")
    Observable<JSONObject> banner(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t);
    //endregion

    //region 主播列表信息 user_useranchor_page
    @FormUrlEncoded
    @POST("user/user-anchor/page")
    Observable<JSONObject> user_useranchor_page(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("type")String type,@Field("Cache")boolean Cache,@Field("P_Get")boolean P_Get,@Field("P_Total")int P_Total
    ,@Field("P_MaxCode")int P_MaxCode,@Field("iDisplayStart")int iDisplayStart,@Field("iDisplayLength")int iDisplayLength
    ,@Field("Sort_Col")String Sort_Col);
    //endregion

    //region 用户列表信息 user_useranchor_page
    @FormUrlEncoded
    @POST("user/user-info/page")
    Observable<JSONObject> user_userinf_page(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("type")String type,@Field("Cache")boolean Cache,@Field("P_Get")boolean P_Get,@Field("P_Total")int P_Total
    ,@Field("P_MaxCode")int P_MaxCode,@Field("iDisplayStart")int iDisplayStart,@Field("iDisplayLength")int iDisplayLength
    ,@Field("Sort_Col")String Sort_Col);
    //endregion

    //region 用户关注列表 attentionlist
    @FormUrlEncoded
    @POST("attentionlist")
    Observable<JSONObject> attentionlist(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("User_ID")String User_ID,@Field("Cache")boolean Cache,@Field("P_Get")boolean P_Get,@Field("P_Total")int P_Total
    ,@Field("iDisplayStart")int iDisplayStart,@Field("iDisplayLength")int iDisplayLength,@Field("Sort_Col")String Sort_Col);
    //endregion

    //region 周星列表信息 weekstartrank
    @FormUrlEncoded
    @POST("weekstartrank")
    Observable<JSONObject> weekstartrank(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("Gift_ID")String Gift_ID,@Field("Length")int Length,@Field("Type")int Type,@Field("Week")int Week
    ,@Field("StartTime")String StartTime,@Field("EndTime")String EndTime);
    //endregion

    //region 用户信息 user_userinfo_info
    @FormUrlEncoded
    @POST("user/user-info/info")
    Observable<JSONObject> user_userinfo_info(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t);
    //endregion

    //region 守护列表 guarduanlist
    @FormUrlEncoded
    @POST("guardianlist")
    Observable<JSONObject> guardianlist(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t);
    //endregion

    //region 贡献榜单 contributionlist
    @FormUrlEncoded
    @POST("contributionlist")
    Observable<JSONObject> contributionlist(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("TopN")int TopN,@Field("User_ID")String User_ID,@Field("OrderBy")String OrderBy);
    //endregion

    //region 用户退出登录 logout
    @FormUrlEncoded
    @POST("logout")
    Observable<JSONObject> logout(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t);
    //endregion

    // region 用户关注 user_userinfo_attention
    @FormUrlEncoded
    @POST("user/user-info/attention")
    Observable<JSONObject> user_userinfo_attention(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
            ,@Field("User_ID_Attention")String User_ID_Attention,@Field("Cancel")String Cancel);
    //endregion

    //region 用户登录qq loginqq
    @FormUrlEncoded
    @POST("login-qq")
    Observable<JSONObject> loginqq(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("qq_id")String qq_id,@Field("qq_token")String qq_token,@Field("qq_expiresin")String qq_expiresin
    ,@Field("qq_refreshtoken")String qq_refreshtoken,@Field("qq_nickname")String qq_nickname,@Field("qq_sex")String qq_sex);
    //endregion

    //region 用户登录weixin loginweixin
    @FormUrlEncoded
    @POST("login-weixin")
    Observable<JSONObject> loginweixin(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t,@Field("weixin_id")String weixin_id
    ,@Field("weixin_uid")String weixin_uid,@Field("weixin_token")String weixin_token,@Field("weixin_expiresin")String weixin_expiresin
    ,@Field("weixin_refreshtoken")String weixin_refreshtoken,@Field("weixin_nickname")String weixin_nickname,@Field("weixin_sex")String weixin_sex);
    //endregion

    //region 用户支付 payorder
    @FormUrlEncoded
    @POST("pay-order")
    Observable<JSONObject> payorder(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Field("pay_type")int pay_type,@Field("pay_amt")double pay_amt,@Field("pay_code")String pay_code);
    //endregion

    //region 上传头像 payorder
    @FormUrlEncoded
    @POST("pay-order")
    Observable<JSONObject> uploadphoto(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
    ,@Part("file\"; filename=\"image.png\"") RequestBody imgs);
    //endregion

    //region 首页主播列表信息 user_useranchor_page
    @FormUrlEncoded
    @POST("user/user-anchor/listhot")
    Observable<JSONObject> user_useranchor_listhot(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
            ,@Field("Start")int Start,@Field("Length")int Length);
    //endregion

    //region 获取验证码
    @FormUrlEncoded
    @POST("phoneverifycode")
    Observable<JSONObject> getCode(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
            ,@Field("Phone")String phone);
    //endregion

    //region 用户注册
    @FormUrlEncoded
    @POST("login-phone")
    Observable<JSONObject> register(@Field("mid")int mid,@Field("sign")String sign,@Field("app_t")int app_t
            ,@Field("Phone")String Phone,@Field("VerifyCode")int VerifyCode,@Field("Password")String Password,@Field("Type")String Type,@Field("_cid")String cid);
    //endregion

    //region 搜索接口
    @FormUrlEncoded
    @POST("user/user-anchor/listanchorsearch")
    Observable<JSONObject> listanchorsearch(@Field("mid")int mid,@Field("app_t")int app_t,@Field("sign")String sign,
                                            @Field("SearchValue")String SearchValue,@Field("Limit")int Limit,@Field("IsHotList")boolean IsHotList,
                                            @Field("HotLimit")int HotLimit,@Field("IsSearch")boolean IsSearch);
    //endregion

    //region 主播认证接口
    @FormUrlEncoded
    @POST("user/user-anchor/applyenter")
    Observable<JSONObject> applyenter(@Field("mid")int mid,@Field("app_t")int app_t,@Field("sign")String sign,
     @Field("Sex")int Sex,@Field("RealName")String RealName,@Field("Phone")String Phone,
     @Field("Account_RealName")String Account_RealName,@Field("Account_CardNo")String Account_CardNo,@Field("Account_BankFullName")String Account_BankFullName,
     @Field("Account_Province")String Account_Province,@Field("Account_City")String Account_City,@Field("Account_BankName")String Account_BankName,
      @Field("QQ")String QQ,@Field("Email")String Email,@Field("IDCard")String IDCard);
    //endregion


    //region 分享接口返回
    @FormUrlEncoded
    @POST("user/user-info/share")
    Observable<JSONObject> share(@Field("mid")int mid,@Field("app_t")int app_t,@Field("sign")String sign, @Field("Share_Flag")int Share_Flag);
    //endregion
}
